Kwik.Page.include("Kwik.Ui.Controls.Control.js");

/** 
* Tab page represents a page and button used for the TabPane.
* @constructor
* @extends Kwik.Ui.Controls.Control
* @requires Kwik.Ui.Controls.Control
* @requires Kwik.Utility
* @created 12:44 PM 5/10/2009
* @modified 12:44 PM 5/10/2009
*/
Kwik.Ui.Controls.TabPage = function(config)
{
	/** @ignore */
	Kwik.Utility.extend(this, "Kwik.Ui.Controls.Control");
	this.__class.push("Kwik.Ui.Controls.TabPage");

	/** Button element for the TabPane @type HTMLDiv */
	this.button = null;

	/** Set the title for this page */
	this.setTitle = function(title)
	{
		this.button.innerHTML = title;
	};

	/** Get title for this page @type String */
	this.getTitle = function()
	{
		return this.button.innerHTML;
	};

	/** Set the body for this page */
	this.setBody = function(body)
	{
		this.element.innerHTML = body;
	};

	/** Get body for this page @type String */
	this.getBody = function()
	{
		return this.element.innerHTML;
	};

	/** Remove this tabpage and it's button from DOM tree if attached */
	this.destroy = function()
	{
		if(this.element.parentNode != null){this.element.parentNode.removeChild(this.element);}
		if(this.button.parentNode != null){this.button.parentNode.removeChild(this.button);}
	};

	/** Configure this tabpage */
	this.configure = function(config)
	{
		Kwik.Page.log.write("Kwik.Ui.Controls.TabPage.configure: Configuring tabpage.");
		config = this.Kwik$Ui$Controls$Control.configure(config);
		if(config.title){this.setTitle(config.title);}
		return config;
	};

	/** Set the element for this tabpage and hides it */
	this.setElement = function(element)
	{
		element.style.display = "none";
		this.Kwik$Ui$Controls$Control.setElement(element);
	};

	/** Event fired when the button is clicked */
	this.onbuttonclick = function(){};

	/** @ignore */
	this.main = function(config)
	{
		this.button = document.createElement("div");
		this.button.className = "Kwik-Ui-Controls-TabButton";
		Kwik.Utility.attachEvent(this.button, "onclick", new Function(this.referenceString() + ".fireEvent(\"onbuttonclick\");"));

		this.setElement(document.createElement("div"));

		if(config){this.configure(config);}
	}; this.main(config);
};